const path = require("path");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');

// 代码分离
const webpack = require('webpack');

module.exports = {
	// 入口文件
	entry: {
		// 起步
		// start: "./src/code-splitting/index.js",

		// 代码分离
		index: "./src/code-splitting/index.js",
		another: "./src/code-splitting/another.js"
	},
	plugins: [
		// new CleanWebpackPlugin(['dist']),	
		new HtmlWebpackPlugin({
			title: "使用HtmlWebpackPlugin"
		}),
		// 指定公共 bundle 的名称
		new webpack.optimize.CommonsChunkPlugin({
			name: "common"
		})
	],
	output: {
		filename: "[name].bundle.js",

		// 起步
		path: path.resolve(__dirname, "dist/code-splitting-06")
	},
	module: {
		rules: [
			{
				test: /\.css$/,
				use: [
					"style-loader",
					"css-loader"
				]
			},
			{
				test: /\.(png|svg|jpg|gif)$/,
				use: [
					"file-loader"
				]
			}

		]
	}
}